package com.srcptit.java.training.kienbd.btvn1;
import java.lang.Math;
public class Muc1Bai8{
    static boolean snt(int n)
    {
	if(n==0||n==1)	return false;
	for(int i=2;i<=Math.sqrt(n);i++)
	{
        	if(n%i==0)	return false;
	}
	return true;
    }
    static boolean kt(int m)
    {
    	int cur, next, n;
	n=m;
	cur=n%10;
	n=n/10;
	if(snt(cur)==true)
	{
        	while(n>0)
		{
                	next=n%10;
			if(next>cur) 		return false;
			if(snt(next)==false)	return false;
			cur=next;
			n=n/10;
		}
		if(snt(m)==true)			return true;
	}					
        return false;
    }
	public static void main(String args[])
	{
		System.out.println("Cac so 7 chu so thoan man : ");
		//int dem=0;
		for(int i=1000000;i<=9999999;i++)
			if(kt(i)==true) 
			{ 
                		System.out.println(i);
				//dem++; 
			}
		//System.out.print("Co "+dem+" so thoa man.");
	}
}
